package homework;

public class homework3 {
    public static void main(String[] args) {

        //算数运算符
        System.out.println(5%2);//商2 余1
        System.out.println(8%2);//商4 余0
        System.out.println(2%5);//商0 余2
        //++单独使用
        int a1=5,a2=5;
        a1++;
        ++a2;
        System.out.println(a1);//6
        System.out.println(a2);//6

        //++被使用
        int a3 = a1++;
        int a4 = ++a2;
        System.out.println(a3);//6
        System.out.println(a4);//7
        System.out.println(a1);//7
        System.out.println(a2);//7

        //关系运算符
        int b1=5,b2=10,b3=5;
        System.out.println(b1>b2);//false
        System.out.println(b3<b2);//true
        System.out.println(b1==b3);//true
        System.out.println(b1>=b2);//false
        System.out.println(b2<=b3);//false
        System.out.println(b2!=b1);//true

        System.out.println(b1++>b3);//false
        System.out.println(b1++>b3);//true
        System.out.println(b1);//7

        //逻辑运算符
        int c1=5,c2=10,c3=5;
        System.out.println(c1==c3 && c1>c2);
        System.out.println(c1>c2 && c3<c2);
        System.out.println(c1<c2 && c2>c3);
        System.out.println(c3>c2 && c2<c1);

        System.out.println(c1==c3 || c3>c2);
        System.out.println(c1>c2 || c3<c2);
        System.out.println(c1<c2 || c3==c1);
        System.out.println(c2<c1 || c3>c1);

        System.out.println(!(c1>c2));//true
        System.out.println(!(c1==c3));//false

        boolean p1 = c1>c2 && c1++>0;
        System.out.println(p1);//false
        System.out.println(c1);//c1=5
        boolean p2 = c1<c2 || c1++>0;
        System.out.println(p2);//true
        System.out.println(c1);//5

        //赋值运算符
        int d1 = 10;
        d1 += 10;
        d1 -= 5;
        d1 *= 2;
        d1 /= 6;
        d1  %= 2;
        System.out.println(d1);//d1=1

        short d2 = 5;
        d2 += 10;
        d2 = (short)(d2 + 10);// byte short char类型参与运算会先转成int类型再运算，所以这里需要进行强转

        //字符串连接
        int age = 88;
        String name = "WKJ";
        System.out.println("我叫"+name+"年龄"+age);
        //字符串的通化作用
        System.out.println(10+20+30+"");//60--String
        System.out.println(""+10+20+30);//102030---String
        System.out.println(10+20+""+30);//3030---String

        //条件运算符(三目运算符)
        int e1 = 5;
        int flage = e1>0?1:0;
        System.out.println(flage);//flage=1

        int e2=5,e3=10;
        System.out.println(e2>e3?e2:e3);//10

//        //if
//        double price = 600.0;
//        if (price >= 500) {
//            price *= 0.8;
//        }
//        System.out.println("程序继续..." + price);
//        double score = 88.0;
//        if (score >= 0 && score <= 100){
//            System.out.println(score+"是合法成绩");
//        }

//        //if...else
//        double price = 600.0;
//        if (price >= 500) {
//            price *= 0.8;
//        }else {
//            price *= 0.9;
//        }
//        System.out.println(price + "程序继续...");
//
//        double score = 88.0;
//        if (score >= 0 && score <= 100){
//            System.out.println(score+"是合法成绩");
//        }else {
//            System.out.println(score+"不是合法成绩");
//        }

        //if...else if
        double price = 400.0;
        if (price >= 2000){
            price *= 0.5;
        }else if (price >= 1000){
            price *= 0.7;
        }else if(price >= 500){
            price *= 0.8;
        }else {
            price *= 0.9;
        }
        System.out.println(price+"程序继续...");

    }
}
